/ Assembly List / LJCDataAccess / DataAccess / ExecuteScript

Namespace - LJCDataAccess


Parameters
scriptFileSpec - The script file specification.

Syntax

C#
public Void ExecuteScript(String scriptFileSpec)

Executes a DB script file. (E)

Example

C#
// See the DataAccess setup code on the DataAccess class page.

// Executes a DB script file.
private static void ExecuteScript(DataAccess dataAccess)
{
  // Create a DB Script file.
  StringBuilder builder = new StringBuilder(64);
  builder.AppendLine("insert into TestTable values('Name1');");
  builder.AppendLine("go");
  builder.AppendLine("delete from TestTable where Name = 'Name1';");
  builder.AppendLine("go");
  string scriptText = builder.ToString();
  File.WriteAllText("TestScript.sql", scriptText);

  dataAccess.ExecuteScript("TestScript.sql");
}

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.